package com.qianfeng.smartdevice.mapper;

import com.qianfeng.smartdevice.pojo.SysCategory;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by wenka on 2022/3/20 21:10
 *
 * @author Jackiechan
 * @version 1.0
 * @since 1.0
 */
public interface SysCategoryMapper {
    /**
     * 添加新的分类
     * @param sysCategory
     */
    @Insert("INSERT INTO sys_category (category_name,tx_command,rx_command,command_name,create_by,create_time) values (#{categoryName},#{txCommand},#{rxCommand},#{commandName},#{createBy},#{createTime})")
    void addCategory(SysCategory sysCategory);

    /**
     * 根据分类id查询
     * @param cid 主键 分类id
     * @return
     */
    @Select("select * from sys_category where c_id=#{cid}")
    SysCategory findByCid(Long cid);

    /**
     * 查询所有分类
     * @return
     */
    @Select("select * from sys_category")
    List<SysCategory> findAll();

    /**
     * 更新数据
     * @param sysCategory
     */
    int updateCategory(SysCategory sysCategory);

    /**
     * 根据id删除数据其实就是更新
     * @param ids
     * @return
     */
    int deleteByIds(@Param("ids") List<Long> ids);

    /**
     * 根据分类名称查询
     * @param CategoryName
     * @return
     */
    @Select("select * from sys_category where category_name=#{CategoryName}")
    SysCategory findByCategoryName(String CategoryName);

}
